Admin Teams notifications and role change requests #105
+2,832
−74
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Adds Microsoft Teams notifications for events that need an administrator, and a way for users to request a different role.
Notifications (Teams)
ADMIN_TEAMS_WEBHOOK_URL, the same Adaptive Card flow the recipe-proposal alerts use) when:platform_notificationsoutbox in the same transaction as the event, with a unique key, so it can't be lost or duplicated. The sign-in check runs on every page load but notifies once per user.Role change requests
Security fix (existing hole)
GET /api/admin/users/{email}/role, the sign-in identity sync, using the system token, so any signed-in user could create or merge someone else's account. The proxy now refuses that route, and the API rejects calls to it that carry a user identity.Also
/api/healthreports whether each notification channel is configured.api/ADMIN_NOTIFICATIONS.md.Deploying
dt-db-migrateJob with the new image; it createsplatform_notificationsandrole_change_requestsand their access rules.PLATFORM_BASE_URLfor the "Open in the platform" links.ADMIN_TEAMS_WEBHOOK_URLis already indt-api-secret.Test plan
api/tests/test_admin_notifications_pg.py): 23/23 on a disposable Postgres 15. It covers first sign-in (once only, invited users, blocked proxied calls), equipment review cycles, the role-request lifecycle with audit, conflict and daily-limit errors, row-level security, delivery (Teams card, email webhook and SMTP, partial refusal, skipped channels, retry/backoff/give-up, stale-claim protection, sanitized errors) and account merging.tsc,eslintandnext buildpass.🤖 Generated with Claude Code